#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int INF = 1e9;

int n, m1, m2;
vector<pii> get_p(int n) {
  vector<pii> ans;
  for (int i = 2; 1ll * i * i <= n; i++) {
    if (n % i) continue;
    int y = 0;
    while (n % i == 0) n /= i, y++;
    ans.push_back(pii(i, y));
  }
  if (n > 1) ans.push_back(pii(n, 1));
  return ans;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  cin >> m1 >> m2;
  vector<pii> primes = get_p(m1);
  for (pii& p : primes) p.second *= m2;
  int ans = INF;
  rep(i, 1, n) {
    int s;
    cin >> s;
    int t = 0;
    for (pii now : primes) {
      int p = now.first, k = now.second;
      int x = 0;
      while (s % p == 0) s /= p, x++;
      if (!x) {
        t = INF;
        break;
      } else
        t = max(t, (k + x - 1) / x);
    }
    ans = min(ans, t);
  }
  if (ans == INF)
    cout << -1;
  else
    cout << ans;
  return 0;
}